/**
 * 
 */
package com.evil.DB_Utils;

/******************************************
 * 工程名：Download<br>
 * 包名：com.evil.DB_Utils<br>
 * 时间：2016年6月10日 下午2:25:12<br>
 * 作者：白雨濃 evil<br>
 * 邮箱：evilbai@foxmail.com<br>
 * 内容：<br>
 ******************************************/
public class UpdateSqlUrl
{
	private static String url = "";

	public static String getUrl(String dbName, String tableName, String[] name,
			String... wheres)
	{
		url = "";
		url += "UPDATE ";
		url += "`" + dbName + "`.";
		url += "`" + tableName + "` SET ";

		for (int i = 0; i < name.length; i++)
		{
			if (i == 0)
				url += "`" + name[i] + "`=" + "?" + "";
			else
				url += ", `" + name[i] + "`=" + "?" + "";
		}

		url += " WHERE (";

		if (wheres.length != 0)
			for (int i = 0; i < wheres.length; i++)
			{
				if (i == 0)
					url += "`" + wheres[i] + "`=" + "?" + "";
				else
					url += ", `" + wheres[i] + "`=" + "?" + "";
			}

		url += ");";
		return url;
	}

	public static String getUrl(String dbName, String tableName, String name,
			String... wheres)
	{
		url = "";
		url += "UPDATE ";
		url += "`" + dbName + "`.";
		url += "`" + tableName + "` SET ";
		url += "`" + name + "`=" + "?" + "";

		url += " WHERE (";

		if (wheres.length != 0)
			for (int i = 0; i < wheres.length; i++)
			{
				if (i == 0)
					url += "`" + wheres[i] + "`=" + "?" + "";
				else
					url += ", `" + wheres[i] + "`=" + "?" + "";
			}

		url += ");";

		return url;
	}
}
